From 2f991e680bea37d1f97ea77df2343200f3899817 Mon Sep 17 00:00:00 2001
From: Anurag <anurag4884@gmail.com>
Date: Wed, 28 Feb 2024 21:13:25 +0530
Subject: feat: initialise a new totals tab with basic UI (#94)

* feat: initialise a new totals tab with basic UI

* fix: update group tabs and add stats page

* fix: styling within the new elements

* Prettier

* Display active user expenses only if active user is set

---------

Co-authored-by: Sebastien Castiel <sebastien@castiel.me>
---
 src/app/groups/[groupId]/stats/totals.tsx | 34 +++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 src/app/groups/[groupId]/stats/totals.tsx

(limited to 'src/app/groups/[groupId]/stats/totals.tsx')

diff --git a/src/app/groups/[groupId]/stats/totals.tsx b/src/app/groups/[groupId]/stats/totals.tsx
new file mode 100644
index 0000000..aa32037
--- /dev/null
+++ b/src/app/groups/[groupId]/stats/totals.tsx
@@ -0,0 +1,34 @@
+'use client'
+import { TotalsGroupSpending } from '@/app/groups/[groupId]/stats/totals-group-spending'
+import { TotalsYourShare } from '@/app/groups/[groupId]/stats/totals-your-share'
+import { TotalsYourSpendings } from '@/app/groups/[groupId]/stats/totals-your-spending'
+import { getGroup, getGroupExpenses } from '@/lib/api'
+import { useActiveUser } from '@/lib/hooks'
+
+export function Totals({
+  group,
+  expenses,
+  totalGroupSpendings,
+}: {
+  group: NonNullable<Awaited<ReturnType<typeof getGroup>>>
+  expenses: NonNullable<Awaited<ReturnType<typeof getGroupExpenses>>>
+  totalGroupSpendings: number
+}) {
+  const activeUser = useActiveUser(group.id)
+  console.log('activeUser', activeUser)
+
+  return (
+    <>
+      <TotalsGroupSpending
+        totalGroupSpendings={totalGroupSpendings}
+        currency={group.currency}
+      />
+      {activeUser && activeUser !== 'None' && (
+        <>
+          <TotalsYourSpendings group={group} expenses={expenses} />
+          <TotalsYourShare group={group} expenses={expenses} />
+        </>
+      )}
+    </>
+  )
+}
-- 
cgit v1.3

